package com.yampi.mahjong.wxapi;

/**
 * Created by 13767 on 2017/10/11.
 */

import android.content.Context;
import android.widget.Toast;

import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.unity3d.player.UnityPlayer;

public class WXApi {

    public IWXAPI wxApi;

    public void RegToWx(Context context, String appId)
    {
        wxApi = WXAPIFactory.createWXAPI(context, appId, true);
        wxApi.registerApp(appId);
    }

    public void Login() {
        if (!wxApi.isWXAppInstalled()) {
            Toast.makeText(UnityPlayer.currentActivity, "您还未安装微信客户端", Toast.LENGTH_SHORT).show();
            return;
        }
        final SendAuth.Req req = new SendAuth.Req();
        req.scope = "snsapi_userinfo";
        req.state = "diandi_wx_login";
        wxApi.sendReq(req);
    }

}
